/*
 * @Author: liu wang wang
 * @Date: 2020-07-13 10:24:17
 * @LastEditTime: 2020-07-13 10:56:31
 * @LastEditors: liu wang wang
 * @Description: 处理post数据
 * @FilePath: \st-sdk-js\src\utils\data.ts
 */
import { isPlainObject } from '../tools'

export function transformRequest(data: any): any {
    if (isPlainObject(data)) {
        return JSON.stringify(data)
    }
    return data
}

export function transformResponse(data: any): any {
    if (typeof data === 'string') {
        try {
            data = JSON.parse(data)
        } catch (e) {
            // o_o
        }
    }
    return data
}